﻿#include "control.h"
#include "ui_control.h"

control::control(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::control)
{
    ui->setupUi(this);
    this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint);
    m_door = false;
    m_airconditioner = false;
    m_window = false;
    m_seat = false;
    m_light = false;
    m_lock = false;
}

control::~control()
{
    delete ui;
}

void control::on_backBtn_clicked()
{
    this->close();
}

void control::on_doorBtn_clicked()
{
    if(!m_door)
    {
        ui->doorBtn->setStyleSheet("border-image: url(:/image/control/door.png);");
        m_door = true;
        ui->doorBtn->setText("");
    }
    else
    {
        ui->doorBtn->setStyleSheet("background-color: rgb(188, 177, 220);color:white;");
        m_door = false;
        ui->doorBtn->setText(QString::fromLocal8Bit("车门 关"));
    }
}
void control::on_airconditionBtn_clicked()
{
    if(!m_airconditioner)
    {
        ui->airconditionBtn->setStyleSheet("border-image: url(:/image/control/airconditioner.png);");
        m_airconditioner = true;
        ui->airconditionBtn->setText("");
    }
    else
    {
        ui->airconditionBtn->setStyleSheet("background-color: rgb(188, 177, 220);color:white;");
        m_airconditioner = false;
        ui->airconditionBtn->setText(QString::fromLocal8Bit("空调 关"));
    }
}
void control::on_lightBtn_clicked()
{
    if(!m_light)
    {
        ui->lightBtn->setStyleSheet("border-image: url(:/image/control/light.png);");
        m_light = true;
        ui->lightBtn->setText("");
    }
    else
    {
        ui->lightBtn->setStyleSheet("background-color: rgb(188, 177, 220);color:white;");
        m_light = false;
        ui->lightBtn->setText(QString::fromLocal8Bit("车灯 关"));
    }

}

void control::on_windowBtn_clicked()
{
    if(!m_window)
    {
        ui->windowBtn->setStyleSheet("border-image: url(:/image/control/window.png);");
        m_window = true;
        ui->windowBtn->setText("");
    }
    else
    {
        ui->windowBtn->setStyleSheet("background-color: rgb(188, 177, 220);color:white;");
        m_window = false;
        ui->windowBtn->setText(QString::fromLocal8Bit("车窗 关"));
    }
}
void control::on_lockBtn_clicked()
{
    if(!m_lock)
    {
        ui->lockBtn->setStyleSheet("border-image: url(:/image/control/lock.png);");
        m_lock = true;
        ui->lockBtn->setText("");
    }
    else
    {
        ui->lockBtn->setStyleSheet("background-color: rgb(188, 177, 220);color:white;");
        m_lock = false;
        ui->lockBtn->setText(QString::fromLocal8Bit("车锁 关"));
    }
}

void control::on_seatBtn_clicked()
{
    if(!m_seat)
    {
        ui->seatBtn->setStyleSheet("border-image: url(:/image/control/seat.jpeg);");
        m_seat = true;
        ui->seatBtn->setText("");
    }
    else
    {
        ui->seatBtn->setStyleSheet("background-color: rgb(188, 177, 220);color:white;");
        m_seat = false;
        ui->seatBtn->setText(QString::fromLocal8Bit("座椅 关"));
    }
}
